package webService;

import java.util.ArrayList;
import java.util.List;

import controllers.AssignCoursesController;
import controllers.AssignDesiredHoursController;
import controllers.CreateProgramController;
import controllers.CreateStudentClassesController;
import controllers.FindStudentController;
import controllers.ManageStudentController;
import model.ClassCourse;
import model.StudentClass;
import model.StudentProfile;
import model.TimeSlot;

public class FrontistirioManagement {

	
	public String findStudent(int studentId)
	{
		FindStudentController fsc=new FindStudentController();
		return(fsc.findStudent(studentId).getFullName());
	}
	
	
	
	public String createStudent(String name,Double gpa)
	{
		ManageStudentController msc=new  ManageStudentController();
		msc.createStudentProfile(name,gpa);
		return ("student with name"+name+ "created");
	}
	
	public String createProgramforClass(int studentClassId)
	{
		  CreateProgramController cpc=new CreateProgramController();
		  
		  StudentClass cStudentClass= cpc.createProgram(studentClassId);
		 	List<ClassCourse> classCourses = cStudentClass.getClassCourses();	    
		 	StringBuffer sBuffer = new StringBuffer();
		 	for(ClassCourse classCourse : classCourses){
			  
			  List<TimeSlot> conductingHours = classCourse.getConductingHours();
			  
			  	for(TimeSlot timeSlot : conductingHours){
			  		sBuffer.append("Course: "+classCourse.getCourse().getDescription() +"  Daytime:"+timeSlot.getDayOfTheWeek()+"\n");
			  	}
			  
			  
		  }
		 	
		  return sBuffer.toString();
	}
	
	public String  createClasses(int minimunClassSize)
	{
		  CreateStudentClassesController  createStudentClassesController=new CreateStudentClassesController();
		  List<StudentClass> classes = createStudentClassesController.createStudentClasses(minimunClassSize);
		  StringBuffer sBuffer = new StringBuffer();
		  
		  for(StudentClass class1 : classes ){
			
			  List<StudentProfile> profiles = class1.getStudents();
			  
			  for(StudentProfile profile : profiles){
				  sBuffer.append("Class: "+class1.getName()+" student: "+profile.getFullName());
			  }
			  
		  }
		  return sBuffer.toString();
	}
	
	public String assignDesiredCourse(int courceId, int studentId)
	{
		AssignCoursesController accAssignCoursesController=new AssignCoursesController();
		ArrayList <Integer> subjectIds=new ArrayList<Integer>();
		subjectIds.add(courceId);
		accAssignCoursesController.assignCourses(subjectIds, studentId);
		return ("Desired courses assignment Succeded");
	}
	
	
	public String assignDesiredHours(String day, int hourStart,int hourStop,int studentId )
	{
		AssignDesiredHoursController acc=new AssignDesiredHoursController();
		ArrayList <String> listDays=new ArrayList<String>();
		ArrayList<Integer> listHourStart=new ArrayList<Integer>();
		ArrayList<Integer> listHourEnd=new ArrayList<Integer>();
		listDays.add(day);
		listHourStart.add(hourStart);
		listHourEnd.add(hourStop);
		acc.assignTimeSlots(listDays, listHourStart, listHourEnd, studentId);
		
		return ("Desired hours assignment Succeded");
	}
	
}
